package mapspinner.persistence.datatypes;

import java.io.IOException;
import java.nio.FloatBuffer;

import com.jme.util.export.InputCapsule;
import com.jme.util.export.JMEImporter;
import com.jme.util.export.OutputCapsule;

public class UncompressedTerrainData implements TerrainData {
	private static final long serialVersionUID = -3370379754588561328L;
	private float[] heightMap;
	private FloatBuffer colorMap;
	private String[] textures;

	public Class<? extends TerrainData> getClassTag() {
		return this.getClass();
	}

	public FloatBuffer getColorMap() {
		return colorMap;
	}

	public float[] getHeightMap() {
		return heightMap;
	}

	public String[] getTextures() {
		return textures;
	}

	public void read(final JMEImporter im) throws IOException {
		final InputCapsule capsule = im.getCapsule(this);
		heightMap = capsule.readFloatArray("heightMap", null);
		colorMap = capsule.readFloatBuffer("colorMap", null);
	}

	public void setColorMap(final FloatBuffer colorMap) {
		this.colorMap = colorMap;
	}

	public void setHeightMap(final float[] heightMap) {
		this.heightMap = heightMap;
	}

	public void setTextures(final String[] textures) {
		this.textures = textures;
	}

	public void write(final com.jme.util.export.JMEExporter ex)
			throws IOException {
		final OutputCapsule capsule = ex.getCapsule(this);
		capsule.write(heightMap, "heightMap", null);
		capsule.write(colorMap, "colorMap", null);
	}
}
